import React, { Component } from 'react'
import ReactDom from 'react-dom'
export default class Index extends Component {
    state = {
        num: 0
    }
    // hClick  = () => {

    //     this.setState({num: this.state.num + 1})
    //     this.setState({num: this.state.num + 2})
    //     this.setState({num: this.state.num + 3})
    //     this.setState({num: this.state.num})
    //     console.log(this.state.num)
    // }
    hClick  = () => {
        this.setState(state =>({num: state.num + 1}))
        debugger
        this.setState(state =>{
            debugger;
            return {num: state.num + 2}},()=>{
            debugger;
            console.log('第2次setSate',this.state.num)})
        this.setState(state =>{
            debugger;
            return {num: state.num + 3}},()=>{console.log('第3次setSate',this.state.num)})
        console.log(this.state.num)
    }
    render() {
        debugger
        console.log('render..')
        return (
            <div>
                num:{this.state.num}
                <button onClick={this.hClick}>修改num</button>
            </div>
        )
    }
}

ReactDom.render(<Index></Index>, document.getElementById('root'))
